﻿@model MediaAdmin.Controllers.PresetController.PresetSummary

@{
    ViewBag.Title = "Create new task preset";
}

<h2>Create new task preset</h2>

        <div id="container">
            <div id="filelist"></div>
            <br />
            <a id="pickfiles" href="javascript:;">[Select file]</a> 
            <a id="uploadfiles" href="javascript:;">[Upload file]</a>
        </div>

    

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")

    <script type="text/javascript" src="http://bp.yahooapis.com/2.4.21/browserplus-min.js"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/plupload/plupload.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/plupload/plupload.gears.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/plupload/plupload.silverlight.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/plupload/plupload.flash.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/plupload/plupload.browserplus.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/plupload/plupload.html4.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/plupload/plupload.html5.js")"></script>

    <script type="text/javascript">
        function $(id) {
            return document.getElementById(id);
        }


        var uploader = new plupload.Uploader({
            runtimes: 'gears,html5,flash,silverlight,browserplus',
            browse_button: 'pickfiles',
            container: 'container',
            max_file_size: '4mb',
            url: '@Url.Action("UploadPreset")',
            flash_swf_url: '@Url.Content("~/Scripts/plupload/plupload.flash.swf")',
            silverlight_xap_url: '@Url.Content("~/Scripts/plupload/plupload.silverlight.xap")'
        });

        //uploader.bind('Init', function (up, params) {
        //    $('filelist').innerHTML = "<div>Current runtime: " + params.runtime + "</div>";
        //});

        uploader.bind('FilesAdded', function (up, files) {
            for (var i in files) {
                $('filelist').innerHTML += '<div id="' + files[i].id + '">' + files[i].name + ' (' + plupload.formatSize(files[i].size) + ') <b></b></div>';
            }
        });

        uploader.bind('UploadProgress', function (up, file) {
            $(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
        });

        $('uploadfiles').onclick = function () {
            uploader.start();
            return false;
        };

        uploader.init();
</script>
}